package common.data.location
{
	import common.model.WqPlanLocate;
	
	import mx.collections.ArrayCollection;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;

	/**
	 * 定位服务类
	 */
	public class LocationService extends RemoteObject
	{
		/**
		 * 接口定位
		 */
		public var findPositionByPhonesHandle:Function;
		/**
		 * 实时定位
		 */
		public var findRealTimePositionByStaffIdListHandle:Function;
		/**
		 * 历史定位
		 */ 
		public var findNearDataGpsHisByDateTimeHandle:Function;
		/**
		 * 计划定位
		 */
		public var findWqPlanLocateHandle:Function;
		/**
		 * 保存或更新计划定位
		 */ 
		public var saveOrUpdateWqPlanLocateHandle:Function;
		/**
		 * 删除计划定位
		 */
		public var deleteWqPlanLocateHandle:Function;
		/**
		 * 计划定位详细
		 */
		public var findWqPlanLocateDetailByPlanIdHandle:Function;
		/**
		 * 历史轨迹
		 */ 
		public var findDataGpsHisByConditionHandle:Function;

		/**
		 * 查询指定员工的客户区域和公司区域
		 */
		public var findRegionsByStaffIdHandle:Function;
		
		public var findPhoneStateHisHandle:Function;
		
		
		public function LocationService()
		{
			super("locationService");
			this.showBusyCursor = false;
			this.getOperation("findPositionByPhones").addEventListener(ResultEvent.RESULT,findPositionByPhonesResult,false,0,true);
			this.getOperation("findRealTimePositionByStaffIdList").addEventListener(ResultEvent.RESULT,findRealTimePositionByStaffIdListResult,false,0,true);
			this.getOperation("findNearDataGpsHisByDateTime").addEventListener(ResultEvent.RESULT,findNearDataGpsHisByDateTimeResult,false,0,true);
			this.getOperation("findWqPlanLocate").addEventListener(ResultEvent.RESULT,findWqPlanLocateResult,false,0,true);
			this.getOperation("findWqPlanLocateDetailByPlanId").addEventListener(ResultEvent.RESULT,findWqPlanLocateDetailByPlanIdResult,false,0,true);
			this.getOperation("saveOrUpdateWqPlanLocate").addEventListener(ResultEvent.RESULT,saveOrUpdateWqPlanLocateResult,false,0,true);
			this.getOperation("deleteWqPlanLocate").addEventListener(ResultEvent.RESULT,deleteWqPlanLocateResult,false,0,true);
			this.getOperation("findDataGpsHisByCondition").addEventListener(ResultEvent.RESULT,findDataGpsHisByConditionResult,false,0,true);
			this.getOperation("findRegionsByStaffId").addEventListener(ResultEvent.RESULT,findRegionsByStaffIdResult,false,0,true);
			this.getOperation("findPhoneStateHis").addEventListener(ResultEvent.RESULT,findPhoneStateHisResult,false,0,true);
			
		}
		
		//接口定位
		public function findPositionByPhones(phones:Array):void{
			this.getOperation("findPositionByPhones").send(phones);
		}
		//回调接口定位
		private function findPositionByPhonesResult(e:ResultEvent):void{
			findPositionByPhonesHandle.call(this,e);
		}
//实时定位		
		//执行实时定位
		public function findRealTimePositionByStaffIdList(staffIdAc:Array):void{
			this.getOperation("findRealTimePositionByStaffIdList").send(staffIdAc);
		}
		
		//回调实时定位
		private function findRealTimePositionByStaffIdListResult(e:ResultEvent):void{
			try{
				if(findRealTimePositionByStaffIdListHandle){
					findRealTimePositionByStaffIdListHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
//历史定位
		//执行历史定位
		public function findNearDataGpsHisByDateTime(staffIdAc:ArrayCollection,dateTime:String):void{
			this.getOperation("findNearDataGpsHisByDateTime").send(staffIdAc,dateTime);
		}
		
		//回调历史定位
		private function findNearDataGpsHisByDateTimeResult(e:ResultEvent):void{
			try{
				if(findNearDataGpsHisByDateTimeHandle){
					findNearDataGpsHisByDateTimeHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
//计划定位
		//执行计划定位查询
		public function findWqPlanLocate():void{
			this.getOperation("findWqPlanLocate").send();
		}
		//回调计划定位查询
		private function findWqPlanLocateResult(e:ResultEvent):void{
			try{
				if(findWqPlanLocateHandle){
					findWqPlanLocateHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//保存或修改计划定位
		public function saveOrUpdateWqPlanLocate(wqPlanLocate:WqPlanLocate,ac:ArrayCollection):void{
			this.getOperation("saveOrUpdateWqPlanLocate").send(wqPlanLocate,ac);
		}
		
		//回调保存或修改计划定位
		public function saveOrUpdateWqPlanLocateResult(e:ResultEvent):void{
			try{
				if(saveOrUpdateWqPlanLocateHandle){
					saveOrUpdateWqPlanLocateHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//删除计划定位
		public function deleteWqPlanLocate(wqPlanLocate:WqPlanLocate):void{
			this.getOperation("deleteWqPlanLocate").send(wqPlanLocate);
		}
		
		//回调删除计划定位
		public function deleteWqPlanLocateResult(e:ResultEvent):void{
			try{
				if(deleteWqPlanLocateHandle){
					deleteWqPlanLocateHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		//执行计划定位详细
		public function findWqPlanLocateDetailByPlanId(planId:String):void{
			this.getOperation("findWqPlanLocateDetailByPlanId").send(planId);
		}
		//回调计划定位详细
		private function findWqPlanLocateDetailByPlanIdResult(e:ResultEvent):void{
			try{
				if(findWqPlanLocateDetailByPlanIdHandle){
					findWqPlanLocateDetailByPlanIdHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
//历史轨迹	
		//执行历史轨迹
		public function findDataGpsHisByCondition(staffId:String,beginDateTime:String,endDateTime:String):void{
			this.getOperation("findDataGpsHisByCondition").send(staffId,beginDateTime,endDateTime);
		}
		
		//回调历史轨迹
		private function findDataGpsHisByConditionResult(e:ResultEvent):void{
			try{
				if(findDataGpsHisByConditionHandle){
					findDataGpsHisByConditionHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		
		public function findRegionsByStaffId(staffId:String,isClient:Boolean,isCompany:Boolean):void{
			this.getOperation("findRegionsByStaffId").send(staffId,isClient,isCompany);
		}
		
		//回调指定员工的客户区域和公司区域
		private function findRegionsByStaffIdResult(e:ResultEvent):void{
			try{
				if(findRegionsByStaffIdHandle){
					findRegionsByStaffIdHandle.call(this,e);
				}
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		public function findPhoneStateHis(staffId:String,beginDateTime:String,endDateTime:String):void{
			this.getOperation("findPhoneStateHis").send(staffId,beginDateTime,endDateTime);
		}
		private function findPhoneStateHisResult(e:ResultEvent):void{
			try{
				findPhoneStateHisHandle.call(this,e);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
	}
}	